// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import './assets/css/mobile.css'

import zh_CN from 'vee-validate/dist/locale/zh_CN'
import VeeValidate,{Validator} from 'vee-validate'
Validator.localize('zh_CN', zh_CN)
// 自定义默认验证消息
const dictionary = {
  zh_CN: {
    messages:{
      required: (field) => {
        let msg = ''
        switch (field) {
          case 'mobile':
            msg = '电话号码'
            break
          case 'code':
            msg = '验证码'
            break
          default:;
        }
        msg = msg + '是必填项！'
        return msg
      }
    }
  }
}
Validator.localize(dictionary)
// 自定义验证规则
Validator.extend('mobile', {
  getMessage: (field) => {
    return '请输入正确的11位手机号码!'
  },
  validate: (value) => {
    let reg = /^1[3|4|5|7|8][0-9]\d{8}$/
    let regTest = /^39{5}\d{5}$/
    return reg.test(value) || regTest.test(value)
  }
})
Vue.use(VeeValidate)


import IScrollView from 'vue-iscroll-view'
import IScroll from 'iscroll'
Vue.use(IScrollView, IScroll)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
